package com.chixing.day13.day13_Home;

import java.util.*;

import static com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver.iterator;

public class FlowTest {
    public static void main(String[] args){
           Map<String,Flow> flow = new HashMap<>();

           //1
           flow.put("刘德华",new Flow("000001","刘德华","0000",'M',"4155990188888888",300.00));
           flow.put("小丽",new Flow("000201","小丽","0002",'F',"4155990199999999",500.00));
           flow.put("黄晓明",new Flow("000101","黄晓明","0012",'M',"4155990100000000",1000.00));
           flow.put("张东健",new Flow("000101","张东健","0012",'M',"4155990155555555",600.00));
           flow.put("梁朝伟",new Flow("000301","梁朝伟","0013",'M',"4155990111111111",500.00));
           flow.put("刘德华",new Flow("000001","刘德华","0000",'M',"4155990188888888",200.00));
           System.out.println(flow);

           //2
           Scanner scanner = new Scanner(System.in);
           System.out.println("请输入姓名:");
           String ename = scanner.next();
           if(flow.containsKey(ename)){
               System.out.println("客户号: " + flow.get(ename).getCustNo() + "\n" +
                                  "姓名: " + flow.get(ename).getCustName() + "\n" +
                                  "所述机构号: " + flow.get(ename).getCompNo() + "\n" +
                                  "性别: " + flow.get(ename).getGender() + "\n" +
                                  "账号: " + flow.get(ename).getUsername() + "\n" +
                                  "发生额: " + flow.get(ename).getCustPrice()
                                   );
           }else {
               System.out.println("查无此人!!!");
           }

           //3
            Map<String,Double> fl = new HashMap<>();
             for (Map.Entry<String, Flow> entry : flow.entrySet()) {
                 if(fl.containsKey(entry.getKey())){
                     fl.put(entry.getKey(), flow.get(entry.getKey()).getCustPrice() + entry.getValue().getCustPrice());
             }else{
                     fl.put(entry.getKey(),flow.get(entry.getKey()).getCustPrice());
                 }
                 System.out.println(entry.getKey() + " " + fl.get(entry.getKey()));
              }




    }
}



